﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using XiaoGang.Soft.XGWMS.BLL;
using XiaoGang.Soft.XGWMS.MODEL;
using XiaoGang.Soft.XGWMS.COM;
using System.IO;
using System.Drawing.Imaging;

namespace XiaoGang.Soft.XGWMS.UI
{
    public partial class M012_MEMBER : FormBase
    {
        #region 定义变量

        enumOperation MOpertion = new enumOperation();
        bool boolClear = false;
        int intFirstDisplayedScrollingRowIndex = 0;

        /// <summary>
        /// 会员
        /// </summary>
        private const string dataName = "会员";
        private bool isInit = true;
        private readonly MOD_M012_MEMBER modMember;
        private readonly BLL_M012_MEMBER bllMember;

        #endregion

        #region 方法

        /// <summary>
        /// 构造函数
        /// </summary>
        public M012_MEMBER()
        {
            InitializeComponent();
            modMember = new MOD_M012_MEMBER();
            bllMember = new BLL_M012_MEMBER();
        }

        /// <summary>
        /// Initial
        /// </summary>
        private void Initial()
        {
            SetControlsIndex();
            InitialGridView();
            InitialControl();
            isInit = false;
        }

        /// <summary>
        /// SetControlsIndex
        /// </summary>
        protected void SetControlsIndex()
        {
            grdMain.TabStop = false;
            int intIndex = 0; intIndex++;
            txtUSER_NO.TabIndex = intIndex; intIndex++;
            txtUSER_NAME.TabIndex = intIndex; intIndex++;
            txtUSER_PHONE1.TabIndex = intIndex; intIndex++;
            txtUSER_ADDRESS1.TabIndex = intIndex; intIndex++;
            txtUSER_EMAIL.TabIndex = intIndex; intIndex++;
            txtUSER_POST.TabIndex = intIndex; intIndex++;
            txtMEMO.TabIndex = intIndex; intIndex++;
            btnAdd.TabIndex = intIndex; intIndex++;
            btnExit.TabIndex = intIndex; intIndex++;
            txtUSER_ID.TabIndex = intIndex; intIndex++;
        }

        /// <summary>
        /// InitialGridView
        /// </summary>
        private void InitialGridView()
        {
            grdMain.AllowUserToAddRows = false;
            grdMain.AllowUserToResizeColumns = true;
            grdMain.AllowUserToDeleteRows = false;
            grdMain.AllowUserToResizeRows = false;
            grdMain.ColumnHeadersHeight = 30;
            grdMain.ColumnHeadersVisible = true;
            grdMain.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            grdMain.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            grdMain.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Raised;
            grdMain.ReadOnly = true;
            grdMain.RowHeadersVisible = false;
            grdMain.RowTemplate.Resizable = DataGridViewTriState.False;
            grdMain.RowTemplate.Height = 25;
            grdMain.RowTemplate.ReadOnly = true;
            grdMain.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            grdMain.ScrollBars = ScrollBars.Both;
            grdMain.TabStop = false;

            grdMain.Columns.Add("NO", "NO.");
            grdMain.Columns.Add("USER_ID", "编号");
            grdMain.Columns.Add("USER_NO", "卡号");
            grdMain.Columns.Add("USER_NAME", "姓名");
            grdMain.Columns["USER_NAME"].Frozen = true;
            DataGridViewButtonColumn btnDelete = new DataGridViewButtonColumn() { Text = "删除", Width = 80, HeaderText = "删除", SortMode = DataGridViewColumnSortMode.NotSortable, Resizable = DataGridViewTriState.False, Frozen = true };
            grdMain.Columns.Add(btnDelete);
            grdMain.Columns.Add("USER_SEX", "性别");
            grdMain.Columns.Add("USER_SEX_HIDE", "");
            grdMain.Columns.Add("USER_BIRTHDAY", "生日");
            grdMain.Columns.Add("USER_PHONE1", "电话");
            grdMain.Columns.Add("USER_PHONE2", "");
            grdMain.Columns.Add("AllPrice", "上次消费");
            DataGridViewButtonColumn btnMoreInfo = new DataGridViewButtonColumn() { Text = "共消费", Width = 100, HeaderText = "共消费", Resizable = DataGridViewTriState.False};
            grdMain.Columns.Add(btnMoreInfo);
            btnMoreInfo.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            //grdMain.Columns.Add("TotalPrice", "共消费");
            grdMain.Columns.Add("USER_ADDRESS1", "住址");
            grdMain.Columns.Add("USER_ADDRESS2", "0");
            grdMain.Columns.Add("USER_EMAIL", "E_Mail");
            grdMain.Columns.Add("USER_POST", "邮编");
            grdMain.Columns.Add("MEMO", "备注");
            grdMain.Columns["NO"].Width = 50;
            grdMain.Columns["NO"].Resizable = DataGridViewTriState.False;
            grdMain.Columns["NO"].SortMode = DataGridViewColumnSortMode.NotSortable;
            grdMain.Columns["USER_ID"].Width = 150;
            grdMain.Columns["USER_ID"].Resizable = DataGridViewTriState.False;
            grdMain.Columns["USER_NO"].Width = 100;
            grdMain.Columns["USER_NO"].Resizable = DataGridViewTriState.False;
            grdMain.Columns["NO"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            grdMain.Columns["USER_NAME"].Width = 100;
            grdMain.Columns["USER_NAME"].Frozen = true;
            grdMain.Columns["USER_NAME"].Resizable = DataGridViewTriState.False;
            grdMain.Columns["USER_SEX"].Width = 50;
            grdMain.Columns["USER_SEX"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            grdMain.Columns["USER_SEX"].Resizable = DataGridViewTriState.False;
            grdMain.Columns["USER_SEX_HIDE"].Width = 0;
            grdMain.Columns["USER_BIRTHDAY"].Width = 120;
            grdMain.Columns["USER_BIRTHDAY"].Resizable = DataGridViewTriState.False;
            grdMain.Columns["USER_PHONE1"].Width = 150;
            grdMain.Columns["USER_PHONE1"].Resizable = DataGridViewTriState.False;
            grdMain.Columns["USER_PHONE2"].Width = 0;
            grdMain.Columns["AllPrice"].Width = 280;
            grdMain.Columns["AllPrice"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            grdMain.Columns["AllPrice"].Resizable = DataGridViewTriState.False;
            //grdMain.Columns["TotalPrice"].Width = 100;
            //grdMain.Columns["TotalPrice"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            //grdMain.Columns["TotalPrice"].Resizable = DataGridViewTriState.False;
            
            grdMain.Columns["USER_ADDRESS1"].Width = 210;
            grdMain.Columns["USER_ADDRESS2"].Width = 0;
            grdMain.Columns["USER_EMAIL"].Width = 120;
            grdMain.Columns["USER_POST"].Width = 100;
            grdMain.Columns["MEMO"].Width = 200;
            grdMain.Columns["USER_SEX_HIDE"].Visible = false;
            grdMain.Columns["USER_PHONE2"].Visible = false;
            grdMain.Columns["USER_ADDRESS2"].Visible = false;


        }

        /// <summary>
        /// InitialControl
        /// </summary>
        private void InitialControl()
        {
            txtUSER_ID.Text = "";
            txtUSER_NO.Text = "";
            txtUSER_NAME.Text = "";
            txtUSER_PHONE1.Text = "";
            txtUSER_ADDRESS1.Text = "";
            txtUSER_EMAIL.Text = "";
            txtUSER_POST.Text = "";
            txtMEMO.Text = "";
        }

        /// <summary>
        /// BindGridData
        /// </summary>
        private void BindGridData()
        {
            if (isInit)
            {
                return;
            }
            grdMain.Rows.Clear();
            ReturnValue returnValue;
            try
            {
                modMember.USER_ID = txtUSER_ID.Text.Trim();
                modMember.USER_NO = this.txtUSER_NO.Text.Trim();
                modMember.USER_NAME = this.txtUSER_NAME.Text.Trim();
                if (ckbM.Checked && ckbF.Checked)
                {
                    modMember.USER_SEX = "";
                }
                else if (ckbM.Checked)
                {
                    modMember.USER_SEX = "0";
                }
                else if (ckbF.Checked)
                {
                    modMember.USER_SEX = "1";
                }
                else
                {
                    modMember.USER_SEX = "2";
                }

                modMember.USER_PHONE1 = this.txtUSER_PHONE1.Text.Trim();
                modMember.USER_ADDRESS1 = this.txtUSER_ADDRESS1.Text.Trim();
                modMember.USER_EMAIL = this.txtUSER_EMAIL.Text.Trim();
                modMember.USER_POST = this.txtUSER_POST.Text.Trim();
                modMember.MEMO = this.txtMEMO.Text.Trim();


                returnValue = bllMember.GetUserList(modMember);
                if (!returnValue.IsSuccess)
                {
                    Method.MessageShow(returnValue.ErrorID, dataName);
                    this.Cursor = Cursors.Default;
                    return;
                }
                grpList.Text = "一览 共" + returnValue.ResultDataSet.Tables[0].Rows.Count.ToString() + "件 [提示：双击记录可查看会员的消费历史]";
                for (int i = 0; i < returnValue.ResultDataSet.Tables[0].Rows.Count; i++)
                {
                    grdMain.Rows.Add((i + 1).ToString(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_ID"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_NO"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_NAME"].ToString().Trim(),                        
                        "删除",
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_SEX"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_SEX_HIDE"].ToString().Trim(),
                        Method.TimeFormat(returnValue.ResultDataSet.Tables[0].Rows[i]["USER_BIRTHDAY"].ToString()),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_PHONE1"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_PHONE2"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["AllPrice"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["TotalPrice"].ToString().Trim() == "" ? "" : string.Format("{0:f2}", decimal.Parse((returnValue.ResultDataSet.Tables[0].Rows[i]["TotalPrice"].ToString().Trim()))),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_ADDRESS1"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_ADDRESS2"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_EMAIL"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_POST"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["MEMO"].ToString().Trim());
                }
            }
            catch
            {
                Method.MessageShow("E11004", dataName);//An unknown error process!
                this.Cursor = Cursors.Default;
            }
            this.Cursor = Cursors.Default;
        }

        /// <summary>
        /// SearchDate
        /// </summary>
        private void SearchDate()
        {
            boolClear = true;
            grdMain.Rows.Clear();
            boolClear = false;
            this.Cursor = Cursors.WaitCursor;
            MOD_M012_MEMBER modMember = new MOD_M012_MEMBER();
            BLL_M012_MEMBER bllMember = new BLL_M012_MEMBER();
            ReturnValue returnValue;
            modMember.USER_ID = this.txtUSER_ID.Text.Trim();
            modMember.USER_NO = this.txtUSER_NO.Text.Trim();
            modMember.USER_NAME = this.txtUSER_NAME.Text.Trim();
            modMember.USER_PHONE1 = this.txtUSER_PHONE1.Text.Trim();
            modMember.USER_ADDRESS1 = this.txtUSER_ADDRESS1.Text.Trim();
            modMember.USER_EMAIL = this.txtUSER_EMAIL.Text.Trim();
            modMember.USER_POST = this.txtUSER_POST.Text.Trim();
            modMember.MEMO = this.txtMEMO.Text.Trim();
            try
            {
                returnValue = bllMember.GetUserList(modMember);
                if (!returnValue.IsSuccess)
                {
                    Method.MessageShow(returnValue.ErrorID, dataName);
                    this.Cursor = Cursors.Default;
                    return;
                }
                //if (returnValue.ResultDataSet.Tables[0].Rows.Count > 12)
                //{
                //    grdMain.Columns["USER_PHONE1"].Width = 83;
                //}
                //else
                //{
                //    grdMain.Columns["USER_PHONE1"].Width = 100;
                //}
                grpList.Text = "一览 共" + returnValue.ResultDataSet.Tables[0].Rows.Count.ToString() + "件 [提示：双击记录可查看会员的消费历史]";
                for (int i = 0; i < returnValue.ResultDataSet.Tables[0].Rows.Count; i++)
                {
                    grdMain.Rows.Add((i + 1).ToString(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_ID"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_NO"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_NAME"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_SEX"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_SEX_HIDE"].ToString().Trim(),
                        Method.TimeFormat(returnValue.ResultDataSet.Tables[0].Rows[i]["USER_BIRTHDAY"].ToString()),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_PHONE1"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_PHONE2"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["AllPrice"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["TotalPrice"].ToString().Trim() == "" ? "" : string.Format("{0:f2}", decimal.Parse((returnValue.ResultDataSet.Tables[0].Rows[i]["TotalPrice"].ToString().Trim()))),
                        "添加",
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_ADDRESS1"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_ADDRESS2"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_EMAIL"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["USER_POST"].ToString().Trim(),
                        returnValue.ResultDataSet.Tables[0].Rows[i]["MEMO"].ToString().Trim());
                }
            }
            catch
            {
                Method.MessageShow("E11004", dataName);//An unknown error process!
                this.Cursor = Cursors.Default;
            }
            this.Cursor = Cursors.Default;
        }

        private bool CheckIsUseUserNo(string UserNO)
        {
            if (UserNO.Length < 1)
            {
                return true;
            }
            BLL_M012_MEMBER bll = new BLL_M012_MEMBER();
            ReturnValue reValue = bll.CheckIsUseUserNo(UserNO);
            if (reValue.IsSuccess)
            {
                if (reValue.ResultDataSet.Tables[0].Rows.Count > 0)
                {
                    Method.MessageShow("W11055", dataName);//本会员有消费记录，不能删除!
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else
            {
                Method.MessageShow(reValue.ErrorID, dataName);
                return false;
            }
        }

        //private bool CheckRepeatUserNo(string UserNO)
        //{
        //    if (UserNO.Trim().Length < 1)
        //    {
        //        return true;
        //    }
        //    BLL_M012_MEMBER bll = new BLL_M012_MEMBER();
        //    ReturnValue reValue = bll.CheckUserNoExist(UserNO);
        //    if (reValue.IsSuccess)
        //    {
        //        if (reValue.ResultDataSet.Tables[0].Rows.Count > 0)
        //        {
        //            Method.MessageShow("W11E01", dataName);//本[@]已经存在。
        //            return false;
        //        }
        //        else
        //        {
        //            return true;
        //        }
        //    }
        //    else
        //    {
        //        Method.MessageShow(reValue.ErrorID, dataName);
        //        return false;
        //    }
        //}

        private bool CheckRepeatUserNo(string UserNO, string UserID)
        {
            if (UserNO.Trim().Length < 1)
            {
                return true;
            }
            BLL_M012_MEMBER bll = new BLL_M012_MEMBER();
            ReturnValue reValue = bll.CheckUserNoExist(UserNO, UserID);
            if (reValue.IsSuccess)
            {
                if (reValue.ResultDataSet.Tables[0].Rows.Count > 0)
                {
                    Method.MessageShow("W11E01", dataName);//本[@]已经存在。
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else
            {
                Method.MessageShow(reValue.ErrorID, dataName);
                return false;
            }
        }

        /// <summary>
        /// 检查会员是否正在使用
        /// </summary>
        /// <param name="MemberID"></param>
        /// <returns>true:使用或发生错误 false:未使用</returns>
        protected bool IsMemberUsed(string MemberID)
        {
            ReturnValue rvReturnValue = bllMember.GetMemberUsed(MemberID);
            if (rvReturnValue.IsSuccess)
            {
                if (rvReturnValue.ResultDataSet.Tables[0].Rows.Count > 0)
                {
                    Method.MessageShow("W11D01", dataName);//本@正在使用!不能删除!
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                Method.MessageShow(rvReturnValue.ErrorID, dataName);
                return true;
            }
        } 

        #endregion        

        #region 事件

        /// <summary>
        /// M012_MEMBER_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void M012_MEMBER_Load(object sender, EventArgs e)
        {
            Initial();
            BindGridData();    
        }

        /// <summary>
        /// btnClear_Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnClear_Click(object sender, EventArgs e)
        {
            if (this.Cursor == Cursors.WaitCursor)
            {
                return;
            }
            InitialControl();
            txtUSER_NAME.Focus();
        }

        /// <summary>
        /// btnExit_Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExit_Click(object sender, EventArgs e)
        {
            if (this.Cursor == Cursors.WaitCursor)
            {
                return;
            }
            this.Close();
        }        

        /// <summary>
        /// M012_MEMBER_KeyUp
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void M012_MEMBER_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.F5:
                    btnAdd_Click(sender, e);
                    break;
                case Keys.F12:
                    btnClear_Click(sender, e);
                    break;
                case Keys.Escape:
                    btnExit_Click(sender, e);
                    break;
            }
        }               

        /// <summary>
        /// btnAdd_Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (this.Cursor == Cursors.WaitCursor)
            {
                return;
            }
            if (new M012MemberEdit().ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                BindGridData();
            }

        }

        /// <summary>
        /// 双击进入编辑
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void grdMain_CellDoubleClick ( object sender, DataGridViewCellEventArgs e )
        {
            if (this.Cursor == Cursors.WaitCursor)
            {
                return;
            }
            if (0 == grdMain.Rows.Count || e.RowIndex == -1)
            {
                return;
            }
            modMember.UPDATER_ID = GlobalVal.gloUserInfo.USER_ID;
            modMember.TERMINAL_CD = GlobalVal.gloUserInfo.TERMINAL_CD;
            modMember.USER_ID = grdMain.CurrentRow.Cells["USER_ID"].Value.ToString();
            modMember.USER_NO = grdMain.CurrentRow.Cells["USER_NO"].Value.ToString();
            modMember.USER_NAME = grdMain.CurrentRow.Cells["USER_NAME"].Value.ToString();
            modMember.USER_SEX = grdMain.CurrentRow.Cells["USER_SEX_HIDE"].Value.ToString();
            modMember.USER_BIRTHDAY = grdMain.CurrentRow.Cells["USER_BIRTHDAY"].Value.ToString();
            modMember.USER_PHONE1 = grdMain.CurrentRow.Cells["USER_PHONE1"].Value.ToString();
            modMember.USER_PHONE2 = grdMain.CurrentRow.Cells["USER_PHONE2"].Value.ToString();
            modMember.USER_ADDRESS1 = grdMain.CurrentRow.Cells["USER_ADDRESS1"].Value.ToString();
            modMember.USER_ADDRESS2 = grdMain.CurrentRow.Cells["USER_ADDRESS2"].Value.ToString();
            modMember.USER_EMAIL = grdMain.CurrentRow.Cells["USER_EMAIL"].Value.ToString();
            modMember.USER_POST = grdMain.CurrentRow.Cells["USER_POST"].Value.ToString();
            modMember.MEMO = grdMain.CurrentRow.Cells["MEMO"].Value.ToString();
            if (new M012MemberEdit(modMember).ShowDialog() == DialogResult.OK)
            {
                //刷新Grid数据
                BindGridData();
            }
        }

        /// <summary>
        /// 查询条件改变时
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void QueryChanged(object sender, EventArgs e)
        {
            if (this.Cursor == Cursors.WaitCursor)
            {
                return;
            }
            BindGridData();
        }

        /// <summary>
        /// 单击 查看消费明细或删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void grdMain_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.Cursor == Cursors.WaitCursor)
            {
                return;
            }
            if (0 == grdMain.Rows.Count)
            {
                return;
            }
            int intColumnIndex = e.ColumnIndex;
            //删除
            if (intColumnIndex == 4 && e.RowIndex != -1)
            {
                //检查该用户是否正在被使用
                if (IsMemberUsed(grdMain.CurrentRow.Cells["USER_ID"].Value.ToString()))
                {
                    this.Cursor = Cursors.Default;
                    return;
                }

                //物理彻底删除
                if (Method.MessageShow("Q22007", dataName) == DialogResult.Yes)//确定要删除该条数据吗?
                {
                    this.Cursor = Cursors.WaitCursor;
                    try
                    {
                        ReturnValue result = bllMember.DeleteMemberPhysical(grdMain.CurrentRow.Cells["USER_ID"].Value.ToString());
                        if (result.IsSuccess)
                        {
                            BindGridData();
                        }
                        else
                        {
                            Method.MessageShow(result.ErrorID, dataName);
                        }
                    }
                    catch
                    {
                        Method.MessageShow("E11004", dataName);//An unknown error process!
                    }
                    finally
                    {
                        this.Cursor = Cursors.Default;
                    }
                }
            }

            //查看消费明细
            if (intColumnIndex == 11 && e.RowIndex != -1)
            {
                string strUSER_NO = grdMain.CurrentRow.Cells["USER_NO"].Value.ToString().Trim();
                if (strUSER_NO.Length > 0)
                {
                    M014_MerberBuy frm = new M014_MerberBuy(grdMain.CurrentRow.Cells["USER_ID"].Value.ToString().Trim(),grdMain.CurrentRow.Cells["USER_NO"].Value.ToString().Trim(), grdMain.CurrentRow.Cells["USER_NAME"].Value.ToString().Trim());
                    frm.ShowDialog();
                    intFirstDisplayedScrollingRowIndex = grdMain.FirstDisplayedScrollingRowIndex;
                    BindGridData();
                    //定位滚动条位置
                    try
                    {
                        grdMain.FirstDisplayedScrollingRowIndex = intFirstDisplayedScrollingRowIndex;
                    }
                    catch { }
                }
                else
                {
                    Method.MessageShow("W11051", dataName);//请为会员设置卡号
                    return;
                }
            }
        }

        #endregion
    }
}